﻿<!DOCTYPE html>
<html>
<head>
	<?php
		if(isset($rub) && $rub="index"){
			error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
			include_once($path.'scripts/pingMachines.php');
			checkMachines($dbh);
	?>
		<meta http-equiv="Refresh" content="30">
	<?php
		}
	?>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title> Exercice BLISS </title>
	<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
	<link rel="stylesheet" type="text/css" href="<?php echo $path; ?>style.css">
	<script type="text/javascript" >
		$(function() {
			
			$("#dialog").dialog({
				autoOpen: false,
				show: {
					effect: "explode",
					duration: 1000
				},
				hide: {
					effect: "explode",
					duration: 1000
				},
				modal: true
			});
			
		});
	</script>
</head>
<body>
	<div id="dialog" title="Erreur de validation">
	</div>
	<?php 
		if(isset($_GET['deco']) && isset($_SESSION['user'])){
			unset($_SESSION['user']);
		}
	    if (isset($_POST['login']) && isset($_POST['pass'])) {
			$num = $dbh->getUserByLogin($_POST['login'],$_POST['pass']);
			if($num != 0){
				$_SESSION['user'] = $num;
			}
			else{
				$message = "Mauvais Login ou mot de passe";
			}
		}		
	?>
	<div id="headerWrapper">
		<?php
			if(isset($_SESSION['user'])){ 
		?>
		<ul>
			<li><a
				href="<?php echo $path; ?>administration/gestion_user.php">Gestion des utilisateurs</a>
			</li>
			<li><a
				href="<?php echo $path; ?>administration/gestion_machine.php">Gestion des machines</a>
			</li>
			<li><a
				href="<?php echo $path; ?>administration/gestion_salle.php">Gestion des salles</a>
			</li>
			<li><a
				href="<?php echo $path; ?>administration/gestion_type_incident.php">Gestion des types d'incident</a>
			</li>
			<li><a
				href="<?php echo $path; ?>administration/gestion_incident.php">Gestion d'incident</a>
			</li>
		</ul>
		<?php
			}elseif(!isset($rub)){
				header('Location: '.$path);
			}else{ 
		?>
			
		<h1>CONNEXION AU SUPERVISEUR !</h1>
		<form method="post" id="form" action="">
			<p>
				<label for="login" class="label">Nom* :</label> 
				<input type="text" id="login" name="login" class="input" />
			</p>
			<p>
				<label for="pass" class="label">Pass* :</label>
				<input type="password" id="pass" name="pass" class="input" />
			</p>
			<p>
				<input type="submit" name="submit" id="submit" class="input" value="Envoyer" />
			</p>
		</form>
		<?php
			} 
		?>
	</div>